import 'package:library1/library1.dart';
import 'package:test/test.dart';

class Person implements Comparable<Person> {
  final String name;
  final int age;

  Person(this.name, this.age);

  @override
  int compareTo(Person other) {
    return age - other.age;
  }

  @override
  String toString() {
    return 'Person{name: $name, age: $age}';
  }
}

void main() {
  Person person1 = Person('Alice', 25);
  Person person2 = Person('Bob', 30);
  Person person3 = Person('Charlie', 25);

  print(person1.compareTo(person2)); // 输出负数，因为 25 < 30
  print(person1.compareTo(person3)); // 输出 0，因为 25 == 25
  print(person2.compareTo(person1)); // 输出正数，因为 30 > 25
}